package com.campus.commons.entity;

import com.baomidou.mybatisplus.annotation.IdType;

import java.util.ArrayList;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableName;
import com.campus.app.mapper.Insert;
import com.campus.app.mapper.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

/**
 * <p>
 * 菜单表
 * </p>
 *
 * @author Rin
 * @since 2020-12-24
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Menu对象", description="菜单表")
@TableName(excludeProperty = {"child","authority"})
public class Menu implements Serializable, GrantedAuthority {
    private String authority;
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "菜单Id")
    @TableId(value = "id", type = IdType.AUTO)
    @Null(groups = Insert.class)
    @NotNull(groups = Update.class,message = "参数Id不能为null")
    @Min(value = 1,message = "参数Id错误",groups = Update.class)
    private Integer id;

    @ApiModelProperty(value = "父级菜单")
    @TableField("pId")
    @NotNull(groups = {Insert.class,Update.class})
    private Integer pid;

    @ApiModelProperty(value = "菜单名称")
    private String title;

    @ApiModelProperty(value = "菜单连接")
    private String href;

    @ApiModelProperty(value = "菜单图标")
    private String icon;

    @ApiModelProperty(value = "菜单的打开方式")
    private String target;

    @ApiModelProperty(value = "前台：1后台：2 其他3")
    private Integer power;

    @ApiModelProperty(value = "菜单排序")
    private Integer sort;

    @ApiModelProperty(value = "是否禁用 1.启用 2.禁用")
    private Integer enabled;

    @ApiModelProperty(value = "1.模块 2.目录 3.菜单 4.功能")
    @TableField("isMenu")
    private Integer ismenu;

    @ApiModelProperty(value = "备注信息")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @TableField("createTime")
    private Date createtime;

    @ApiModelProperty(value = "更新菜单时间")
    @TableField("updateTime")
    private Date updatetime;
    @ApiModelProperty(value = "菜单权限名")
    @TableField("menu_Pn")
    private String menuPn;

    private List<Menu> child=new ArrayList<>();

    public Menu(Integer id) {
        this.id = id;
    }

    @Override
    public String getAuthority() {
        return authority;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }
}
